<?php
class p_cast extends Model
{
    public $id;
	public $programme_id;
	public $cast_role_id;
	public $created_at;
	public $modified_at;
	public $gender;
	public $age;
	public $blog_url;
	public $real_first_name;
	public $real_first_name_zh;
	public $real_first_name_en;
	public $real_last_name;
	public $real_last_name_zh;
	public $real_last_name_en;
	public $real_name;
	public $real_name_zh;
	public $real_name_en;
	public $other_name;
	public $other_name_zh;
	public $other_name_en;
	public $nickname;
	public $nickname_zh;
	public $nickname_en;
	public $occupation;
	public $occupation_zh;
	public $occupation_en;
	public $personality;
	public $personality_zh;
	public $personality_en;
	public $profile;
	public $profile_zh;
	public $profile_en;
	public $history;
	public $history_zh;
	public $history_en;
	public $video_type;
	public $premium_title;
	public $premium_title_zh;
	public $premium_title_en;
	public $ppv_flag;
	public $ppv_online_time;
	public $ppv_offline_time;
	public $ppv_country_allow_list;
	public $ppv_country_deny_list;
	public $subscription_flag;
	public $subscription_free_flag;
	public $subscription_online_time;
	public $subscription_offline_time;
	public $subscription_country_allow_list;
	public $subscription_country_deny_list;

    public static function getTableName()
    {
        return 'p_cast';
    }

    public function set($obj)
    {
        foreach (get_object_vars($this) as $field=>$value) {
            $this->$field = isset($obj->$field) ? $obj->$field : '';
        }
    }

    public function insert($obj)
    {
        return Model::$dbo['w']->save($obj);
    }

    public function update($obj)
    {
        return Model::$dbo['w']->save($obj);
    }

    public function delete($obj)
    {
        return Model::$dbo['w']->deleteInstance($this->getTableName(),$obj->id);
    }

    public function findCastNotInId(array $id=array(), $programme_id)
    {
        return Model::$dbo['r']->find(__CLASS__, "programme_id=? AND id NOT IN(" . implode(',', $id) . ")", array($programme_id));
    }
}
?>
